<template>
  <div v-if="cdLists">
    <div class="detailstop">
      <div class="pus">
        <img src="../../assets/Search/1.png" @click="$router.go(-1)" />
      </div>
      <div class="url">
        <img :src="cdLists.artist.picUrl" />
      </div>
      <h1>{{ cdLists.artist.name }}</h1>
      <span>2370万 粉丝</span>
      <div class="collect">
        <img
          src="../../assets/Search/47.png"
          @click="Edit"
          v-show="true == isEdit"
        />
        <img
          src="../../assets/Search/48.png"
          @click="Edit"
          v-show="true != isEdit"
        />
      </div>
    </div>

    <div class="various">
      <ul>
        <li
          v-for="(item, index) in tabTitle"
          :key="index"
          @click="num = index"
          :class="{ con: num == index }"
        >
          {{ item }}
        </li>
      </ul>

      <div :class="['content', { con: num == 0 }]">
        <div class="cdSingle">
          <div class="onetouch">
            <span>时间排序</span>
          </div>
          <ul>
            <li
              v-for="(item, index) in cdLists.hotSongs"
              :key="index"
              @click="addByEnterKey(item.id)"
            >
              <div class="alpic">
                <img :src="item.al['picUrl']" alt="" />
              </div>
              <div class="lile">
                <div>{{ item.name }}</div>
                <div>{{ item.ar[0].name }} {{ item.al.name }}</div>
              </div>
              <div class="lirig">
                <img src="../../assets/Search/12.png" alt="" />
              </div>
            </li>
          </ul>
        </div>
      </div>

      <div :class="['content', { con: num == 1 }]">
        <div class="Allists">
          <ul>
            <li v-for="(item, index) in AlLists.hotAlbums" :key="index">
              <div class="mvtu">
                <img :src="item.blurPicUrl" alt="" />
              </div>
              <div class="mvna">
                <span>{{ item.name }}</span>
                <span
                  >{{ item.publishTime | formatDate }} ({{ item.size }}首)</span
                >
              </div>
              <div class="mvjin">
                <img src="../../assets/Search/13.png" alt="" />
              </div>
            </li>
          </ul>
        </div>
      </div>

      <div :class="['content', { con: num == 2 }]">
        <div class="mvlists">
          <ul>
            <li
              v-for="(item, index) in mvLists.mvs"
              :key="index"
              @click="qwe(item.id)"
            >
              <div class="mvtu">
                <img :src="item.imgurl" alt="" />
              </div>
              <div class="mvna">
                <span>{{ item.name }}</span>
                <span>{{ item.publishTime }}</span>
              </div>
              <div class="mvjin">
                <img src="../../assets/Search/13.png" alt="" />
              </div>
            </li>
          </ul>
        </div>
      </div>

      <div :class="['content', { con: num == 3 }]">
        <div class="details">
          <div class="attestation">
            <h3>认证信息</h3>
            <div class="news">
              <img src="../../assets/Search/14.png" alt="" />
              <span>歌手</span>
            </div>
          </div>
          <div class="means">
            <h3>歌手资料</h3>
            <div class="xqmeans">{{ deLists.briefDesc }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {
  getSingerd,
  getSingerdMv,
  getSingerdAlbum,
  getSingerddetails,
  // getSingerdresemble,
  getSingerdsub,
} from "../../api/cdSing";

export default {
  data() {
    return {
      // cdid:null,
      cdLists: null,
      mvLists: [],
      AlLists: [],
      deLists: {},
      num: 0,
      tabTitle: ["单曲", "专辑", "MV", "关于TA"],
      isEdit: true,
      mvcc: "",
      don: 1,
    };
  },
  methods: {
    Edit() {
      this.isEdit = !this.isEdit;
      if (!this.isEdit) {
        this.don = 1;
        this.FungetSingerdsub();
        this.isEdit = false;
      } else {
        this.don = 0;
        this.FungetSingerdsub();
        this.isEdit = true;
      }
    },

    qwe(id) {
      this.$router.push({ name: "getinto", query: { userId: id } });
    },
    addByEnterKey(id) {
      this.$parent.getPlayerId(id);
    },

    FungetSingerdsub() {
      getSingerdsub({ id: this.mvcc, t: this.don }).then((data) => {
        // if (data.code =200) {
        console.log(data);
        // }
      });
    },
  },

  filters: {
    formatDate: function (value) {
      let date = new Date(value);
      let y = date.getFullYear();
      let MM = date.getMonth() + 1;
      MM = MM < 10 ? "0" + MM : MM;
      let d = date.getDate();
      d = d < 10 ? "0" + d : d;
      // let h = date.getHours();
      // h = h < 10 ? "0" + h : h;
      // let m = date.getMinutes();
      // m = m < 10 ? "0" + m : m;
      // let s = date.getSeconds();
      // s = s < 10 ? "0" + s : s;
      return y + "-" + MM + "-" + d;
      // return y + "-" + MM + "-" + d + " " + h + ":" + m + ":" + s;
    },
  },

  created() {
    this.mvcc = this.$route.query.id;
    // console.log(this.$route.query.id);

    getSingerd(this.mvcc).then((res) => {
      this.cdLists = res;
      // console.log(this.cdLists);
    });

    getSingerdMv(this.mvcc).then((data) => {
      this.mvLists = data;
      // console.log(this.mvLists);
    });

    getSingerdAlbum(this.mvcc).then((data) => {
      this.AlLists = data;
      // console.log(this.AlLists);
    });

    getSingerddetails(this.mvcc).then((res) => {
      this.deLists = res.data.artist;
    });
  },
};
</script>

<style lang="less">
.detailstop {
  width: 100%;
  height: 270px;
  box-sizing: border-box;
  // background: palevioletred;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
  // background: url(../../assets/Search/11.png) no-repeat center;
  // background-size: 100% 130%;
  position: relative;
  color: white;
  .url {
    width: 100%;
    height: 100%;
    img {
      width: 100%;
      height: 100%;
      border-bottom-left-radius: 20px;
      border-bottom-right-radius: 20px;
    }
  }
  .pus {
    width: 25px;
    height: 25px;
    float: left;
    position: fixed;
    top: 15px;
    left: 15px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  h1 {
    position: absolute;
    top: 70%;
    left: 5%;
    color: gray;
  }
  span {
    position: absolute;
    top: 85%;
    left: 5%;
    font-size: 9px;
    color: gray;
  }
  button {
    width: 60px;
    height: 25px;
    // color: black;
    border: 1px solid gray;
    background: gray;
    border-radius: 15px;
    font-size: 13px;
    position: absolute;
    top: 85%;
    right: 6%;
  }
  .collect {
    position: absolute;
    top: 15px;
    right: 15px;
    img {
      width: 20px;
    }
  }
}
.various {
  width: 100%;
  ul {
    height: 40px;
    width: 100%;
    margin-top: 5px;
    li {
      width: 25%;
      height: 40px;
      float: left;
      line-height: 40px;
      text-align: center;
      &.con {
        font-weight: bold;
        color: white;
        border-radius: 30px;
        background-color: gray;
      }
    }
  }
  .content {
    width: 100%;
    display: none;
    .cdSingle {
      width: 100%;
      padding-top: 15px;
      padding-left: 20px;
      padding-right: 15px;
      box-sizing: border-box;
      .onetouch {
        width: 70px;
        height: 30px;
        font-size: 9px;
        border: 1px solid gray;
        box-sizing: border-box;
        border-radius: 20px;
        display: flex;
        justify-content: center;
        align-items: center;
      }
      ul {
        width: 100%;
        li {
          width: 100%;
          height: 55px;
          box-sizing: border-box;
          padding-top: 10px;
          padding-bottom: 10px;
          // border-bottom: 1px solid gray;
          display: flex;
          .alpic {
            width: 10%;
            padding-top: 5px;
            padding-right: 5px;
            img {
              width: 35px;
              height: 35px;
              border-radius: 50%;
            }
          }
          .lile {
            width: 80%;
            height: 100%;
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            div:nth-child(1) {
              height: 50%;
              font-size: 14px;
              margin-top: -5px;
            }
            div:nth-child(2) {
              font-size: 9px;
              margin-top: 3px;
              color: gray;
            }
          }
          .lirig {
            width: 10%;
            padding-top: 10px;
            display: flex;
            align-items: center;
            img {
              width: 20px;
              height: 20px;
            }
          }
        }
      }
    }
    .mvlists {
      width: 100%;
      margin-top: 10px;
      padding-top: 10px;
      ul {
        width: 100%;
        li {
          width: 100%;
          height: 80px;
          box-sizing: border-box;
          // padding-left: 15px;
          // padding-right: 15px;
          padding: 5px 15px;
          display: flex;
          .mvtu {
            width: 25%;
            height: 100%;
            // background: brown;
            border-radius: 10px;
            img {
              width: 100%;
              height: 100%;
              border-radius: 10px;
            }
          }
          .mvna {
            width: 55%;
            height: 100%;
            display: flex;
            flex-direction: column;
            span {
              width: 100%;
              height: 40px;
              display: inline-block;
              margin-left: 5px;
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
              text-align: initial;
            }
            span:nth-child(2) {
              font-size: 9px;
              color: gray;
            }
          }
          .mvjin {
            width: 20%;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            img {
              width: 20px;
              height: 20px;
            }
          }
        }
      }
    }
    .Allists {
      width: 100%;
      margin-top: 10px;
      padding-top: 10px;
      ul {
        width: 100%;
        li {
          width: 100%;
          height: 80px;
          box-sizing: border-box;
          padding: 5px 15px;
          display: flex;
          .mvtu {
            width: 25%;
            height: 100%;
            border-radius: 20px;
            img {
              width: 100%;
              height: 100%;
              border-radius: 20px;
            }
          }
          .mvna {
            width: 55%;
            height: 100%;
            display: flex;
            flex-direction: column;
            span {
              width: 100%;
              height: 40px;
              display: inline-block;
              margin-left: 5px;
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
              text-align: initial;
            }
            span:nth-child(2) {
              font-size: 9px;
              color: gray;
            }
          }
          .mvjin {
            width: 20%;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            img {
              width: 20px;
              height: 20px;
            }
          }
        }
      }
    }
    .details {
      width: 100%;
      padding-top: 20px;
      padding-left: 15px;
      padding-right: 15px;
      box-sizing: border-box;
      .attestation {
        width: 100%;
        height: 70px;
        // background-color: plum;
        h3 {
          font-weight: bold;
        }
        .news {
          width: 100%;
          box-sizing: border-box;
          margin-top: 7px;
          display: flex;
          img {
            width: 20px;
            height: 20px;
          }
          span {
            padding-left: 5px;
            font-size: 13px;
            color: gray;
          }
        }
      }
      .means {
        width: 100%;
        height: 170px;
        h3 {
          font-weight: bold;
        }
        .xqmeans {
          width: 100%;
          height: 150px;
          margin-top: 10px;
          color: gray;
          text-indent: 2em;
          word-wrap: break-word;
          word-break: break-all;
          overflow-y: auto;
          text-overflow: ellipsis;
        }
      }
    }
  }
  .content.con {
    display: block;
  }
}
</style>